package com.zw.yzk.kabu.mapper;

import com.zw.yzk.kabu.data.network.entity.MallItemEntity;
import com.zw.yzk.kabu.model.GoodsModel;
import com.zw.yzk.kabu.model.MallItemModel;
import com.zw.yzk.kabu.utils.CalculateUtils;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

/**
 * Created by zhanwei on 2017/2/27.
 */

public class MallItemMapper {

    @Inject
    public MallItemMapper() {

    }

    public List<MallItemModel> transfer(MallItemEntity entity) {
        List<MallItemModel> result = new ArrayList<>();
        if (entity.result == null) {
            return result;
        }
        for (MallItemEntity.Type type : entity.result.typeList) {
            MallItemModel model = new MallItemModel();
            model.setComtent(type.comtent);
            model.setHomeImge(type.homeImge);
            model.setType(type.type);
            List<MallItemModel.Item> itemList = new ArrayList<>();
            if (type.itemList != null && !type.itemList.isEmpty()) {
                for (MallItemEntity.Item i : type.itemList) {
                    MallItemModel.Item item = new MallItemModel.Item();
                    item.setType(i.type);
                    item.setId(i.id);
                    item.setImg(i.img);
                    item.setLinkType(i.linkType);
                    item.setLinkUrl(i.linkUrl);
                    item.setSubTitle(i.subTitle);
                    item.setTitle(i.title);

                    itemList.add(item);
                }
            }
            model.setItemList(itemList);
            result.add(model);
        }
        return result;
    }


}
